<?php
include("utils.php");
$mode = $_POST['mode'];
if($mode == 'UserRegistration')
{                                
editRegistration();
}
else
{
main_content("main();");
//main();
}

############################## function to update user account starts#########################
function editRegistration(){
//print_r($_REQUEST);
 $sql_update_account="update ".SITEUSER." set username = '".$_REQUEST['UserName']."', password = '".$_REQUEST['PassWord']."', fName = '".$_REQUEST['FirstName']."', lName = '".$_REQUEST['LastName']."', email = '".$_REQUEST['EmaiL']."', phone = '".$_REQUEST['MOBIle']."', company = '".$_REQUEST['CompName']."' where siteuserId = '".$_SESSION['siteuserId']."'";

$exe_update_account=mysql_query($sql_update_account);
if($exe_update_account)
{
	$GLOBALS['regmsg']="Account Information Updated Successfully";
}
else
{
	$GLOBALS['regmsg']="Failed To Update Account Information";
}
main_content("main();");
}
############################## function to update user account ends ############################

function main()
{
$select_edit_account="select * from ".SITEUSER." where siteuserId = '".$_SESSION['siteuserId']."'";
$exe_edit_account=mysql_query($select_edit_account);
$row_edit_account=mysql_fetch_array($exe_edit_account);

$sql_status_advertiser="select siteuserId from ".ADVERTISEMASTER." where siteuserId = '".$_SESSION['siteuserId']."'";
$exe_status_advertiser=mysql_query($sql_status_advertiser);
$num_status_advertiser=mysql_num_rows($exe_status_advertiser);

$sql_status_publisher="select UserId from ".ADSPSCEMASTER." where UserId = '".$_SESSION['siteuserId']."'";
$exe_status_publisher=mysql_query($sql_status_publisher);
$num_status_publisher=mysql_num_rows($exe_status_publisher);

?> 
<script language="javascript" src="JavaScripts/registration.js"></script>
<link href="css/global.css" rel="stylesheet" type="text/css">
<!--<link rel="stylesheet" href="css/style.css" type="text/css" />-->
<form id="myAccountForm" name="myAccountForm" method="post" action="" onsubmit="return regformvalidation();">

<input type="hidden" name="mode" value="UserRegistration" /><br>
<br>

<table width="90%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td valign="top" align="center"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="20%"><?php include("left_pannel.php"); ?></td>
                    <td style="width:10px;">&nbsp;</td>
                    <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td width="11"><img src="images/PinkBorderTopLeft.jpg" alt="" width="11" height="11"></td>
                              <td class="PinkBoxTopBg"><img src="images/spacer.gif" alt="" width="10" height="11"></td>
                              <td width="11"><img src="images/PinkBorderTopRight.jpg" alt="" width="11" height="11"></td>
                            </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td class="PinkTwosideBorder"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<body id="tab1">
<ul id="tabnav">
<!--<li class="tab1"><a href="my_account.php?sid=<?php// echo $_REQUEST['sid'];?>">Summary</a></li>-->
<li class="tab1"><a href="my_account.php">Summary</a></li>
<li class="tab2"><a href="edit_advertiser.php">Advertiser</a></li>
<li class="tab3"><a href="edit_publisher.php">Publisher</a></li>
</ul>
</body>
				<tr><td colspan="2" style="color:#FF0000; font-weight:bold;font-size:12px" align="center"><?php if($GLOBALS['regmsg']!=''){ echo $GLOBALS['regmsg'];} ?></td></tr>
                              <tr>
                                <td width="154" valign="top">&nbsp;</td>
                                <td valign="top"><table border="0" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td width="100" height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg" width="30">UserName:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td width="14">&nbsp;</td>
                                    <td><input name="UserName" type="text" class="InputBox" id="UserName" value="<?php echo $row_edit_account['username'];?>"><span id="UserNameError" style="display:none; color:#FF0000; font-weight:bold; font-size:11px;"></span></td>
                                    <td width="11">&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>
				  <tr>
                                    <td width="100" height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg">UserType:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td width="14">&nbsp;</td>
                                 <td class="font-12 black advertise_tableTxt"><input type="radio" name="userType" <?php if($num_status_advertiser > 0){ ?> checked="checked"<?php } ?>>&nbsp;Advertiser
					<input type="radio" name="userType" <?php if($num_status_publisher > 0){ ?> checked="checked"<?php } ?>>&nbsp;Publisher</td>
                                    <td width="11">&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>
                                  <tr>
                                    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg">Password:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td>&nbsp;</td>
                                    <td><input name="PassWord" type="password" class="InputBox" id="PassWord" value="<?php echo $row_edit_account['password'];?>"><span id="PassWordError" style="display:none; color:#FF0000; font-weight:bold; font-size:11px;"></span></td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>
                                  <tr>
                                    <td height="30" width="100"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg" width="30">Retype Password:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td>&nbsp;</td>
                                    <td><input name="RPassWord" type="password" class="InputBox" id="RPassWord" value="<?php echo $row_edit_account['password'];?>"><span id="RPassWordError" style="display:none; color:#FF0000; font-weight:bold; font-size:11px;"></span></td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>
                                  <tr>
                                    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg">First Name:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td>&nbsp;</td>
                                    <td><input name="FirstName" type="text" class="InputBox" id="FirstName" value="<?php echo $row_edit_account['fName'];?>"><span id="FirstNameError" style="display:none; color:#FF0000; font-weight:bold; font-size:11px;"></span></td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>
                                  <tr>
                                    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg">Last Name:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td>&nbsp;</td>
                                    <td><input name="LastName" type="text" class="InputBox" id="LastName" value="<?php echo $row_edit_account['lName'];?>"><span id="LastNameError" style="display:none; color:#FF0000; font-weight:bold; font-size:11px;"></span></td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>

                                  <tr>
                                    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg">Email:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td>&nbsp;</td>
                                    <td><input name="EmaiL" type="text" class="InputBox" id="EmaiL" value="<?php echo $row_edit_account['email'];?>"><span id="EmaiLError" style="display:none; color:#FF0000; font-weight:bold; font-size:11px;"></span></td>
                                <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>

                                  <tr>
                                    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg">Phone number:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td>&nbsp;</td>
                                    <td><input name="MOBIle" type="text" class="InputBox" id="MOBIle" value="<?php echo $row_edit_account['phone'];?>"><span id="MOBIleError" style="display:none; color:#FF0000; font-weight:bold; font-size:11px;"></span></td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>
                                  <tr>
                                    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg">Company Name:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td>&nbsp;</td>
                                    <td><input name="CompName" type="text" class="InputBox" id="CompName" value="<?php echo $row_edit_account['company'];?>"><span id="CompNameError" style="display:none; color:#FF0000; font-weight:bold; font-size:11px;"></span></td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>

                                  <tr>
                                    <td height="30">&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <td align="right" valign="bottom"><input name="Submit" type="submit" class="SubmitInputButton" id="submit" value="Save"><input type="hidden" name="SubmitForm" id="SubmitForm" value="Register" /></td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>

                                </table></td>
                              </tr>
                            </table></td>
                      </tr>
                      <tr>
                        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td width="11"><img src="images/PinkBorderBottomLeft.jpg" alt="" width="11" height="11"></td>
                              <td class="PinkBoxBottomBg"><img src="images/spacer.gif" alt="" width="10" height="11"></td>
                              <td width="11"><img src="images/PinkBorderBottomRight.jpg" alt="" width="11" height="11"></td>
                            </tr>
                        </table></td>
                      </tr>
                    </table></td>
                    <td>&nbsp;</td>
                    </tr>
                </table></td>
              </tr>
            </table>
</form>
            
<?php
        //include("footer.php");
}
		?> 